package com.wmh.baseservice.robot.controller;

import com.wmh.baseservice.common.utils.returnbody.ReturnBody;
import com.wmh.baseservice.robot.service.RobotInfoService;
import com.wmh.baseservice.robot.service.RobotStatusService;
import com.wmh.baseservice.robot.service.RobotTaskService;
import com.wmh.baseservice.robot.service.RobotTaskTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author 青石
 */
@Api(tags = "自动化机器-超级管理员", value = "超级管理员")
@RestController
@RequestMapping("superAdmin/robot")
@RequiresRoles("超级管理员")
@Validated
public class SuperAdRobotController {

    @Resource
    private HttpServletRequest request;

    @Resource
    private RobotStatusService robotStatusService;

    @Resource
    private RobotTaskService robotTaskService;

    @Resource
    private RobotTaskTemplateService robotTaskTemplateService;

    @Resource
    private RobotInfoService robotInfoService;


    @ApiOperation("获取机器日志")
    @PostMapping("getLog")
    public String getLog(Long robotNumber){
        String robotLog = robotInfoService.getRobotLog(robotNumber);
        return ReturnBody.success(robotLog);
    }

    @ApiOperation("注销机器")
    @PostMapping("logoutRobot")
    public String logout(Long robotNumber){
        robotInfoService.logout(robotNumber);
        return ReturnBody.success();
    }

    @ApiOperation("获取机器截图")
    @PostMapping("getScreenshots")
    public String getScreenshots(Long robotNumber){
        return ReturnBody.success(robotInfoService.getScreenshots(robotNumber));
    }
}
